package com.多态.基础;
class People{
    void habit(){
        System.out.println("打游戏");
    }
}
class Student extends People{

    void habit1(){
        System.out.println("学习");
    }
}
public class 向下转型 {
    public static void main(String[] args) {
        People people = new Student();
//        people.habit1();//报错，无法使用子类的方法
        //向下转型
        if (people instanceof Student) {
            Student student = (Student) people;
            student.habit1();
            student.habit();//使用父类的方法
        }
    }
}
